package com.db.service.email;

import com.db.domain.bank.Client;
import com.db.domain.bank.ClientRegistrationListener;

public class EmailNotificationListener implements ClientRegistrationListener {

    private EmailService emailService;

    public EmailNotificationListener(EmailService emailService) {
        this.emailService = emailService;
    }

    @Override
    public void onClientAdded(Client c) {
        if(!emailService.sendNotificationEmail(new Email(c, "email@to"))) {
            System.err.println("Can't send notification for client " + c.getName() + " . Sorry, please try again later.");
        }
    }
}
